#define _CRT_SECURE_NO_WARNINGS 1

#include "DoubleLinkedList.h"

void TestFront();
void TestBack();
void TestInsert();
void TestErase();
void TestClear();

int main() {
	TestFront();
	TestBack();
	TestInsert();
	TestErase();
	TestClear();
	return 0;
}

void TestFront() {
	ListNode* list = InitList();
	PushFront(list, 100);
	PushFront(list, 200);
	PushFront(list, 300);
	PushFront(list, 400);
	PushFront(list, 500);
	PrintList(list);
	PopFront(list);
	PopFront(list);
	PopFront(list);
	PopFront(list);
	PopFront(list);
	PopFront(list);
	PrintList(list);
}

void TestBack() {
	ListNode* list = InitList();
	PushBack(list, 100);
	PushBack(list, 200);
	PushBack(list, 300);
	PushBack(list, 400);
	PrintList(list);

	PopBack(list);
	PopBack(list);
	PopBack(list);
	PopBack(list);
	PrintList(list);
}

void TestInsert() {
	ListNode* list = InitList();
	PushBack(list, 100);
	Insert(Find(list, 100), 200);
	Insert(Find(list, 200), 300);
	Insert(Find(list, 300), 400);
	PrintList(list);
}

void TestErase() {
	ListNode* list = InitList();
	PushBack(list, 100);
	PushBack(list, 200);
	PushBack(list, 300);
	PushBack(list, 400);
	PushBack(list, 500);
	PrintList(list);
	Erase(Find(list, 100));
	PrintList(list);
	Erase(Find(list, 500));
	PrintList(list);
	Erase(Find(list, 300));
	PrintList(list);
}

void TestClear() {
	ListNode* list = InitList();
	PushBack(list, 100);
	PushBack(list, 200);
	PushBack(list, 300);
	PushBack(list, 400);
	PushBack(list, 500);
	PrintList(list);
	Clear(list);
	list = NULL;
	PrintList(list);
}